import requests

from basic.config import ENV


def adminLogin():
    url = ENV.ADM_HOST+'/api/admin/merchant/login'
    headers = {'content-type': 'application/json'}
    json_data = {
        'account': '18292417675',
        'pwd': '000000',
        'captchaVO': {},
        'captcha': {
            'captchaVerification': '',
            'secretKey': '',
            'token': '',
        },
    }
    response = requests.post(url, headers=headers,json=json_data)
    return response.json()['data']['token']

def frontLogin():
    url=ENV.FONT_HOST+'/api/front/login/mobile/password'
    headers = {'content-type': 'application/json'}
    json_data = {
        'phone': '17362124646',
        'password': 'a123456',
        'spreadPid': 0,
    }
    response = requests.post(url,headers=headers,json=json_data)
    resp_dict = response.json()
    token_str = resp_dict.get('data', {}).get('token', '')
    print(token_str)
    return token_str.split(':')[-1]
